   /*the default options for jquery.form plugin */
   var options = {
        beforeSubmit:  ShowLoader,  // pre-submit callback
        success:       showResponse,  // post-submit callback
        dataType:   "json"        // 'xml', 'script', or 'json' (expected server response type)
    };


	function showResponse(data, statusText, xhr, $form){
		$("#submit_section input[type='submit']").removeAttr("disabled");
      if(data.success){
//    	  alert("location: " + data.success);
//    	  window.location = data.success; 
    	  $("#message").html('<div class="success">'+data.success+'</div>').show();
    	  window.location = data.link;
    	  //window.location = data.link;
      }
      if(data.error){
    	  if(data.islogin){
    		  alert(data.error);
    	  }
    	  else{
	         $("#message").html('<div class="error"><ul>'+data.error+'</ul></div>').show();
	         window.location = data.link;
    	  }
      }
      if(data.refresh){
    	  var delay = 0;
    	  if(data.delay){
    		  delay = data.delay;
    	  }
    	  else{
    		  delay = 1;
    	  }
    	  setTimeout("location.reload(true)", delay*1000); 
         //location.reload(true);
      }
      if(data.redirect)	{
    	  window.location = data.redirect;
      }
      if(data.back)	{
		history.back();
  	 }
  	 
      HideLoader();
   }

  function ShowLoader()
   {
     //$("#message").hide();
	  $("#submit_section input[type='submit']").attr("disabled", "disabled");
     var h=$(window).height();
     $("#loader").css({height:h, opacity: 0.5});
     $("#loaderimg").css({margin: h/2-200});
     $("#loader").show();
   }
  function HideLoader()
   {
     $("#loader").hide();
   }
  
   /* Submit a form, ajax post method */
   function Send(id_form){
       $(id_form).ajaxSubmit(options);
	   return false;
   }